import service from "./service";
import { getProjectManager } from "@/scripts/getProjectManager";
import loading from "./loading";

const getModelser2Ip = () => {
    const objm = getProjectManager()
    return objm.modelser2Manager.modelser2Url.match(/^(https?:\/\/[^\/]+)/)?.[1]
}


// 创建任务
export const reqCreateTask = (data: any) => {
    loading.showLoading("正在提交任务，请稍后...")
    const getInfoData = service({
        url: `${getModelser2Ip()}/ts/editor`,
        method: 'post',
        data
    })
    return getInfoData
}

// 随机获取一个Tile的范围
export const reqGetRandomTile = (tileServiceName:string) => {
    const getInfoData = service({
        url: `${getModelser2Ip()}/ts/datasetref/tile/bound?tileServiceName=${tileServiceName}`,
        method: 'get',
    })
    return getInfoData
}

// 编辑历史
export const reqGetHistory = (data: any) => {
    const getInfoData = service({
        url: `${getModelser2Ip()}/ts/editor/list`,
        method: 'post',
        data
    })
    return getInfoData
}

// 创建单体化
export const reqCreateMonomer = (data: any) => {
    const getInfoData = service({
        url: `${getModelser2Ip()}/ts/dantihua/create`,
        method: 'post',
        data
    })
    return getInfoData
}

// 根据经纬度获取单体化
export const reqGetMonomer = (data: any) => {
    const getInfoData = service({
        url: `${getModelser2Ip()}/ts/dantihua/getbycondition`,
        method: 'post',
        data
    })
    return getInfoData
}
